<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>编辑Banner</title>
    <%@ include file="../../common/meta.jsp" %>
    <%@ include file="../../common/common-body.jsp" %>
    <link href="${ctx}/css/page/common-win.css?t=${now}" rel="stylesheet">
    <script src="${ctx}/js/common/myDateTimeFormat.js?t=${now}"></script>
    <script src="${ctx}/js/common/upLoadingFileSize.js?t=${now}"></script>
    <script src="${ctx}/js/plugins/validate/jquery.validate.custom.js?t=20181127"></script>
    <script src="${ctx}/js/plugins/jquery.ajaxfileupload-2.1.js?t=${now}"></script>
    <script src="${ctx}/js/imageview/jquery.photo.gallery.js?t=${now}"></script>
    <link href="${ctx}/css/plugins/note/note.css?t=${now}" rel="stylesheet">
    <script src="${ctx}/js/plugins/note/note.js?t=${now}"></script>
    <style>
        .note{
            border: 1px solid #e5e6e7 ;
            width: 100%;
            height: 150px;
            overflow-y:auto;
        }
        .divNote {
            height: 130px
        }
    </style>
    <script>
        var imgSrcDefault = "${ctx}/images/main/default.jpg";
        var bannerDto = ${bannerDto};
        var searchInfo = ${searchInfo};
        var type = '${type}';
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="tabs-container">
        <div class="myContent">
            <div class="tabs-container">
                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins myIbox">
                                    <div class="ibox-title">
                                        <h5 class="page-header page-header-new"><c:if test="${type == 'add'}">新增</c:if>
                                            <c:if test="${type == 'edit'}">编辑</c:if>
                                            banner</h5>
                                    </div>
                                    <div id="_div1" class="ibox-content">
                                        <form class="form-horizontal m-t" id="bannerForm" name="bannerForm" autocomplete="off">
                                            <div class="form-group">
                                                <input type="hidden" id="hiddenId" name="id" value="${not empty bannerDto ? bannerDto.id : ''}"/>
                                                <input type="hidden" id="bannerType" name="bannerType" value="${not empty bannerDto ? bannerDto.bannerType : ''}"/>
                                                <label class="col-sm-2 control-label"><span style="color: red">*</span>标题：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" id="title" name="title" maxlength="50"  class="form-control" value="${not empty bannerDto ? bannerDto.title : ''}" required/>
                                                </div>
                                                <label class="col-sm-2 control-label">简称：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" maxlength="50" id="shortName" name="shortName" value="${not empty bannerDto.shortName ?bannerDto.shortName :""}">
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">链接：</label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control" id="linkUrl" name="linkUrl" value="${not empty bannerDto.linkUrl ?bannerDto.linkUrl :""}" >
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"><span style="color: red">*</span>有效时间：</label>
                                                <div class="col-sm-8">
                                                    <input placeholder="有效时间" type="text" value="${not empty bannerDto ? bannerDto.activeTime : ''}" class="form-control layer-date" id="activeTime"  required>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <c:if test="${bannerDto.bannerType == 'hc_lesson_detail'}">
                                                <label class="col-sm-2 control-label"><span style="color: red">*</span>课程分类：</label>
                                                <div class="col-sm-3">
                                                    <select  class="form-control" id="contentType" name="contentType" required>
                                                        <c:forEach items="${contentType}" var="item">
                                                            <option value="${item.key}"
                                                                ${not empty bannerDto.contentType && bannerDto.contentType == item.key ? 'selected' : '' }
                                                            >${item.value}</option>
                                                        </c:forEach>
                                                    </select>
                                                </div>
                                                </c:if>
                                                <label class="col-sm-2 control-label">排序：</label>
                                                <div class="col-sm-3">
                                                    <input type="text"  id="sortNum" name="sortNum"  class="form-control" maxlength="9"  value="${not empty bannerDto ? bannerDto.sortNum : ''}" isPInteger="true"/>
                                                    <span class="help-block m-b-none tip"></span>
                                                </div>
                                            </div>

                                        <c:if test="${bannerDto.bannerType != 'bh_index'}">
                                            <div class="form-group">
                                                <div class="col-sm-2 control-label divNote" style="height: 100px"><span style="color: red">*</span>对应渠道：
                                                    <div>
                                                        <input type="button"  class="btn btn-primary btn-outline" onclick="addSource()" value="添加渠道" />
                                                    </div>
                                                </div>
                                                <div class="col-sm-8">
                                                    <div class="note" id="source"  name="source" readonly="true">
                                                        <c:forEach items="${bannerDto.sourceList}" var="item" >
                                                            <div class="note_lable"  name="source" value="${item.sourceCode}">
                                                                <lable>${item.sourceName}</lable>
                                                                <div  onclick="$(this).parent().remove()">X</div>
                                                                <div  class="note_mind"></div>
                                                            </div>
                                                        </c:forEach>
                                                    </div>
                                                </div>
                                                <label class="note_error" style="display: none;"><i class="fa fa-times-circle"></i>必选</label>
                                            </div>
                                        </c:if>

                                        <c:if test="${bannerDto.bannerType == 'hc_lesson_detail'}">
                                            <div class="form-group">
                                                <div class="col-sm-2 control-label divNote" style="height: 100px"><span style="color: red">*</span>一级科室：
                                                    <div>
                                                        <input type="button"  class="btn btn-primary btn-outline" onclick="addDept()" value="添加科室" />
                                                    </div>
                                                </div>
                                                <div class="col-sm-8">
                                                    <div class="note" id="deptOne"  name="deptOne" readonly="true">
                                                        <c:forEach items="${bannerDto.deptRefList}" var="item" >
                                                            <div class="note_lable"  name="deptOne" value="${item.deptCode}">
                                                                <lable>${item.deptName}</lable>
                                                                <div  onclick="$(this).parent().remove()">X</div>
                                                                <div  class="note_mind"></div>
                                                            </div>
                                                        </c:forEach>
                                                    </div>
                                                </div>
                                                <label class="note_error" style="display: none;"><i class="fa fa-times-circle"></i>必选</label>
                                            </div>
                                        </c:if>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"><span style="color: red">*</span>图标：</label>
                                                <div class="col-sm-8">
                                                    <div  class="col-sm-2">
                                                        <div class="gallerys">
                                                            <img style="float: left" id="picUrl"
                                                                 class="img-rounded img-header gallery-pic"
                                                                 onclick='$.openPhotoGallery(this)'
                                                                 src="${not empty bannerDto.picUrl && not empty bannerDto.picUrl?bannerDto.picUrl:ctx}${not empty bannerDto&&not empty bannerDto.picUrl ?'':'/images/main/default.jpg'}">
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-10" style="text-align: left;">
                                                        <label class="ui-upload">浏览
                                                            <input type="file" id="imgThumb" name="imgThumb" style="left:-9999px;position:absolute;" onchange="onPreviewImg(this, 'picUrl')" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
                                                        </label>
                                                        <c:if test="${bannerDto.bannerType == 'hc_lesson_detail'}">
                                                            <label style="float: left;width: 100%;margin-left: 20px;">图片尺寸要求：750*180px，60k以内</label>
                                                        </c:if>
                                                        <c:if test="${bannerDto.bannerType == 'hc_lesson_index'}">
                                                            <label style="float: left;width: 100%;margin-left: 20px;">图片尺寸要求：500*250px，60k以内</label>
                                                        </c:if>
                                                        <c:if test="${bannerDto.bannerType == 'bh_index'}">
                                                            <label style="float: left;width: 100%;margin-left: 20px;">图片尺寸要求：710*180，60k以内</label>
                                                        </c:if>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                        <div class="ibox float-e-margins">
                                            <div class="ibox-content">
                                                <div class="form-group" id="_btnDiv1">
                                                    <div class="col-sm-4 col-sm-offset-5">
                                                        <input type="button" class="btn btn-primary" onclick="doCheckImage()" value="保存">
                                                        <input type="button" class="btn btn-white" onclick="doCheckDataChange()" value="返回">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${ctx}/js/plugins/validate/jquery.validate.custom.js?t=20181024"></script>
<script src="${ctx}/js/operative/win/editBannerManage.js?t=${now}"></script>

<div id="selectDept" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 id="assOneLevelDept">添加科室</h4>
                <form>
                    <label class="col-sm-3 text-right control-label">科室名称：</label>
                    <div class="col-sm-7"><input type="text" class="form-control" placeholder="输入科室名称"
                                                 onkeydown="if(event.keyCode==13){doDeptRefresh();return false;}"
                                                 id="deptName"  name="deptName"></div><div class="col-sm-2 text-center">
                    <bttton type="button" class="btn btn-white" onclick="doDeptRefresh()">查询</bttton>
                </div>
                </form>
            </div>

            <div class="modal-body modal-body-height">
                <div style="border: 1px solid #e4eaec;-webkit-box-shadow:0px 3px 3px #c8c8c8 ;
-moz-box-shadow:0px 3px 3px #c8c8c8 ;
box-shadow:0px 3px 3px #c8c8c8 ;">
                    <table data-toggle="table"  id="dataDeptTable"
                           data-pagination="true"
                           data-side-pagination="server" data-striped="true"
                           data-url="${ctx}/operative/banner/findDeptList?t=${now}"
                           data-response-handler="handleServerResult" data-query-params-type=""
                           data-query-params="getParams"
                           data-cache="true" data-page-size="${defaultPageSize}"
                           data-page-list="${pageList}">
                        <thead>
                        <tr>
                            <th data-field="checkBx" data-checkbox="true" data-width="30px" ></th>
                            <th data-field="deptName"data-align="center" ><span style="font-weight:bold">一级科室</span></th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="modal-footer text-center" style="text-align: center;">
                <button class="btn btn-primary" onclick="clickDept()">确定</button>
                <button class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div id="selectSource" class="modal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 id="assSource">添加渠道</h4>
                <form>
                    <label class="col-sm-3 text-right control-label">渠道名称：</label>
                    <div class="col-sm-7"><input type="text" class="form-control" placeholder="输入渠道名称"
                                                 onkeydown="if(event.keyCode==13){doSourceRefresh();return false;}"
                                                 id="sourceName"  name="sourceName"></div><div class="col-sm-2 text-center">
                    <bttton type="button" class="btn btn-white" onclick="doSourceRefresh()">查询</bttton>
                </div>
                </form>
            </div>

            <div class="modal-body modal-body-height">
                <div style="border: 1px solid #e4eaec;-webkit-box-shadow:0px 3px 3px #c8c8c8 ;
-moz-box-shadow:0px 3px 3px #c8c8c8 ;
box-shadow:0px 3px 3px #c8c8c8 ;">
                    <table data-toggle="table"  id="dataSourceTable"
                           data-pagination="true"
                           data-side-pagination="server" data-striped="true"
                           data-url="${ctx}/operative/banner/findSourceList?t=${now}"
                           data-response-handler="handleServerResult" data-query-params-type=""
                           data-query-params="getParams"
                           data-cache="true" data-page-size="${defaultPageSize}"
                           data-page-list="${pageList}">
                        <thead>
                        <tr>
                            <th data-field="checkBx" data-checkbox="true" data-width="30px" ></th>
                            <th data-field="sourceName"data-align="center" ><span style="font-weight:bold">渠道名称</span></th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="modal-footer text-center" style="text-align: center;">
                <button class="btn btn-primary" onclick="clickSource()">确定</button>
                <button class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
